package com.eric.api.feign;

import com.eric.api.dto.ProductDto;
import entity.CommonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author:Eric
 * @date:2021/7/8
 */
@FeignClient(value = "product-service")
public interface ProductFeign {

    /**
     * 新增
     *
     * @param product
     * @return
     */
    @PostMapping("/product")
    CommonResult insert(@RequestBody ProductDto product);

    /**
     * 修改
     *
     * @param product
     * @return
     */
    @PutMapping("/product")
    CommonResult update(@RequestBody ProductDto product);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/product/{id}")
    CommonResult delete(@PathVariable(value = "id") Long id);

    /**
     * 获取一个
     *
     * @param id
     * @return
     */
    @GetMapping("/product/{id}")
    CommonResult getOne(@PathVariable(value = "id") Long id);

    /**
     * 减库存
     *
     * @param product
     * @return
     */
    @PostMapping("/product/reduce")
    CommonResult reduce(@RequestBody ProductDto product);
}
